<?php

namespace api\controller;

use common\controller\VerifyController;
use common\service\DepartmentReportService;
use common\service\WorkTimeRecordService;
use think\Request;

class DepartmentReportController extends VerifyController
{
    /**
     * @var WorkTimeRecordService
     */
    private $departmentReportService;

    public function __construct()
    {
        parent::__construct();
        $this->departmentReportService = DepartmentReportService::getInstance();
    }

    /**
     * 部门报表-列表
     * @param Request $request
     * @return \think\Response
     */
    public function list(Request $request)
    {
        $filter = $request->param()['param']['filter'];
        $res = $this->departmentReportService->list($filter);
        return json(success_response('', $res));
    }

    /**
     * 部门报表-详情
     * @param Request $request
     * @return \think\Response
     */
    public function detail(Request $request)
    {
        $filter = $request->param()['param']['filter'] ?? null;
        $isAbnormal = $request->param()['param']['is_abnormal'] ?? null;
        $category = $request->param()['param']['category'] ?? null;
        $grade = $request->param()['param']['grade'] ?? null;
        $page = $request->param()['param']['page'] ?? [1, C("database.database_max_select_rows")];
        $res = $this->departmentReportService->detail($filter, $request->param()['param'], $isAbnormal, $category, $grade, $page);
        return json(success_response('', $res));
    }

}
